package com.qcxk.yuqian.rtu.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.qcxk.yuqian.rtu.entity.Files;
import com.qcxk.yuqian.rtu.mapper.FilesMapper;
import com.qcxk.yuqian.rtu.service.IFilesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.qcxk.yuqian.system.component.QueryWrapperConverter;

/**
 * @auther lp
 * @create 2021-05-29 05:40:57
 * @describe 服务实现类
 */
@Service
public class FilesServiceImpl extends ServiceImpl<FilesMapper, Files> implements IFilesService {
    @Autowired
    private FilesMapper filesMapper;

    @Override
    public Page queryFilesPage(Page page, Files files) {

        QueryWrapper<Files> filesQueryWrapper = new QueryWrapper<>();
        QueryWrapperConverter.converter(filesQueryWrapper, files);

        filesQueryWrapper.orderByDesc("ctime");
        filesMapper.selectPage(page, filesQueryWrapper);
        return page;
    }

    @Override
    public boolean deleteFilesById(Files files) {
        int re = filesMapper.deleteById(files.getId());
        return re == 1 ? true : false;
    }
}
